package com.thoughtworks.kontinuum.report;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.GregorianCalendar;

public class ReportLog {

	String logLocation = "";
	Date lastReportTime;
	static String reportName = "konReportLog.txt";
	
	public ReportLog(String reportLogLocation){
		logLocation = reportLogLocation;
	}
	
	private String getFullFilePath(){
		return logLocation+reportName;
	}
	
	public void parse() throws Exception{
	    FileInputStream fstream = new FileInputStream(getFullFilePath());
	    DataInputStream in = new DataInputStream(fstream);
	    BufferedReader br = new BufferedReader(new InputStreamReader(in));
	    String strLine;
	    while ((strLine = br.readLine()) != null)   {
	      lastReportTime = new Date(strLine);
	    }
	}
	
	public void generate() throws Exception{
		FileWriter fileWriter = new FileWriter(logLocation);
		GregorianCalendar now = new GregorianCalendar();
		fileWriter.write(now.getTime().toString());
		fileWriter.close();
	}
	
}
